import { userAccountLogin } from '@/api/user'
// 用户状态
export default {
  namespaced: true,
  state: () => ({
    profile: {
      id: '',
      nickname: '',
      avatar: '',
      token: '',
      mobile: ''
    }
  }),
  mutations: {
    setUser (state, palyLoad) {
      state.profile = palyLoad
    },
    clearProfile (state) {
      state.profile = {
        id: '',
        nickname: '',
        avatar: '',
        token: '',
        mobile: ''
      }
      localStorage.clear()
    }
  },
  actions: {
    async asyncUserProfile (ctx, { account, password }) {
      const res = await userAccountLogin({ account, password })
      ctx.commit('setUser', res.data.result)
    }
  },
  getters: { }
}
